import { http } from '@/utils/http'
import type { UploadProgressCallback } from '@/types/api'

export const fileApi = {
  // 上传文件
  upload: (file: File, onProgress?: UploadProgressCallback) => {
    const formData = new FormData()
    formData.append('file', file)
    return http.upload<{ url: string; filename: string; size: number }>(
      '/api/file/upload', 
      formData, 
      onProgress
    )
  }
}
// 导出 http 实例以便特殊需求使用
export { http }